package com.teemor.blog.controller;


import com.teemor.blog.api.IArticleTagsApiService;
import com.teemor.blog.bean.condition.TbArticleTagsCondition;
import com.teemor.blog.bean.dto.input.articletags.AddArticleTagsIPo;
import com.teemor.blog.bean.dto.input.articletags.QryArticleTagssIPo;
import com.teemor.blog.bean.dto.input.articletags.UpdArticleTagsIPo;
import com.teemor.blog.bean.dto.output.articletags.QryArticleTagsOPo;
import com.teemor.blog.bean.dto.output.articletags.QryArticleTagssOPo;
import com.teemor.blog.bean.entity.TbArticleTags;
import com.teemor.blog.service.IArticleTagsService;
import com.teemor.common.bean.utils.BeanConvertor;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: zhoulk
 * @Description: 原子服务API接口实现
 * @date: 2020/03/14 18:00:12
 */
@RestController
public class ArticleTagsController implements IArticleTagsApiService {
    @Autowired
    private IArticleTagsService iArticleTagsService;

    @Override
    public QryArticleTagsOPo qryArticleTags(@PathVariable Integer id) {
        return BeanConvertor.convertBean(iArticleTagsService.qryArticleTagsById(id), QryArticleTagsOPo.class);
    }

    @Override
    public int countArticleTags(@RequestBody QryArticleTagssIPo inParam) {
        TbArticleTagsCondition condition = BeanConvertor.convertBean(inParam, TbArticleTagsCondition.class);
        return iArticleTagsService.countArticleTags(condition);
    }

    @Override
    public List<QryArticleTagssOPo> qryArticleTagss(@RequestBody QryArticleTagssIPo inParam) {
        TbArticleTagsCondition condition = BeanConvertor.convertBean(inParam, TbArticleTagsCondition.class);
        return BeanConvertor.convertBeanList(iArticleTagsService.qryArticleTagss(condition), QryArticleTagssOPo.class);
    }

    @Override
    public void updArticleTags(@RequestBody UpdArticleTagsIPo inParam) {
        TbArticleTags tbArticleTags = BeanConvertor.convertBean(inParam, TbArticleTags.class);
        iArticleTagsService.updArticleTagsById(tbArticleTags);
    }

    @Override
    public void addArticleTags(@RequestBody AddArticleTagsIPo inParam) {
        TbArticleTags tbArticleTags = BeanConvertor.convertBean(inParam, TbArticleTags.class);
        iArticleTagsService.addArticleTags(tbArticleTags);
    }
}